/*
 *  linmigrate - base interface declaration
 *
 *  Copyright (C) 2011 by Volodymyr M. Shcherbyna <volodymyr@shcherbyna.com>
 *
 *      This file is part of linmigrate.
 *
 *  linmigrate is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  linmigrate is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with linmigrate.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef IDISTRIBUTIONHANDLER_H
#define IDISTRIBUTIONHANDLER_H

#include <QProcess>
#include <QDir>
#include <QFile>
#include <QTextStream>
#include <QMap>

#include <stdio.h>
#include <stdlib.h>
#include <sys/vfs.h>
#include <sys/stat.h>

enum IDistribution
{
    Unknown     = 0x00,
    Debian      = 0x01,
    Ubuntu      = 0x02,
    Mint        = 0x03,
    Fedora      = 0x04,
    OpenSUSE    = 0x05
};

struct ExportOptions
{
    ExportOptions() : bExcludeSymlinks(false)
    {

    }

    bool bExcludeSymlinks;
};

struct ImportOptions
{
    ImportOptions() : szImportFile("")
    {

    }

    QString szImportFile;
};

class IDistributionHandler : public QMap<int, IDistributionHandler*>
{
public:
    IDistributionHandler(QTextStream & console);
public:
    virtual IDistribution Identify() = 0;    
    virtual int Export(ExportOptions & options) = 0;
    virtual int Import(ImportOptions & options) = 0;
protected:
    virtual bool GetFolderSize(QString & szPath);
    virtual bool GetFreeDiskSpace(QString & szPath);
    virtual bool CompressDirectory(QString & szPath);
    virtual bool UnCompressDirectory(QString & szPath, QString & szPathWhere);
    virtual bool CleanDirectory(const QString & szPath);
    virtual bool CopyHostsFile(const QString & szPath);
    virtual bool CopyXorgFile(const QString & szPath);
    virtual bool CopyRCLocalFile(const QString & szPath);
    virtual bool CopyFstabFile(const QString & szPath);
    virtual bool CopyDirectory(const QString & szPathTo, const QString & szPathFrom, bool bExcludeSymlinks, QString & szExcludeDir);
    virtual bool CopyFile(const QString & szFrom, const QString & szTo);
protected:
    QTextStream & m_console;
};

#endif // IDISTRIBUTIONHANDLER_H
